<script>
	import {getDistinguishClassId} from '@/network/api/classification.js'
	uni.onTabBarMidButtonTap(()=>{
		const str = Math.random().toString(36).substr(2, 15);
		const fileName = str+".png"
		
		uni.chooseImage({
			count: 1, //默认9
			sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
			// sourceType: ['album'], //从相册选择,默认两者都有
			success: function (res) {
			     const tempFilePaths = res.tempFilePaths[0];
				uni.uploadFile({
							url: 'http://192.168.196.216:1234/classification/upload', //仅为示例，非真实的接口地址
							filePath: tempFilePaths,
							name: 'file',
							timeout:10000,
							formData:{
								"fileName":fileName,
							},
							success: (uploadFileRes) => {
								//获得识别的classId的值
								const query = {
									"fileName":fileName
								}
								var classId = 0
								const dataJSON = JSON.parse(uploadFileRes.data)
								console.log(dataJSON.data)
								uni.redirectTo({
									url:'/pages/classinfo/classinfo?fileName='+fileName,
								})
								// getDistinguishClassId(query).then(result=>{
								// 	classId = result.data
									
								// })
								//跳转到详情页面
							},
		
						});
			},
		});
	})
	export default {
		onLaunch: function() {
			console.log('App Launch')
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		},
	}
</script>

<style>
	/*每个页面公共css */
</style>
